﻿using AutoMapper;
using Enferno.Public.InversionOfControl;
using Enferno.Public.Web.Models;
using Enferno.StormApiClient.Products;
using Enferno.StormApiClient.Shopping;

namespace Enferno.Public.Web.Mappers.Resolvers
{
    public class ProductItemOnHandStatusResolver<TOnHandStatusModel> : ValueResolver<ProductItem, TOnHandStatusModel>
        where TOnHandStatusModel: OnHandStatusModel, new()
    {
        protected override TOnHandStatusModel ResolveCore(ProductItem productItem)
        {
            var siteRules = IoC.Resolve<ISiteRules>();

            return siteRules.GetOnHandStatus<TOnHandStatusModel>(productItem);
        }
    }

    public class ProductOnHandStatusResolver<TOnHandStatusModel> : ValueResolver<Product, TOnHandStatusModel>
        where TOnHandStatusModel: OnHandStatusModel, new()
    {
        protected override TOnHandStatusModel ResolveCore(Product product)
        {
            var siteRules = IoC.Resolve<ISiteRules>();

            return siteRules.GetOnHandStatus<TOnHandStatusModel>(product);
        }
    }

    public class BasketOnHandStatusResolver<TOnHandStatusModel> : ValueResolver<Basket, TOnHandStatusModel>
        where TOnHandStatusModel: OnHandStatusModel, new()
    {
        protected override TOnHandStatusModel ResolveCore(Basket basket)
        {
            var siteRules = IoC.Resolve<ISiteRules>();

            return siteRules.GetOnHandStatus<TOnHandStatusModel>(basket);
        }
    }

    public class WarehouseOnHandStatusResolver<TOnHandStatusModel> : ValueResolver<Warehouse, OnHandStatusModel>
        where TOnHandStatusModel: OnHandStatusModel, new()
    {
        protected override OnHandStatusModel ResolveCore(Warehouse warehouse)
        {
            var siteRules = IoC.Resolve<ISiteRules>();

            return siteRules.GetOnHandStatus<TOnHandStatusModel>(warehouse);
        }
    }
}
